/**
 * 
 */

package com.wutianyi.thrift.example.noblocking;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TNonblockingServer.Args;
import org.apache.thrift.transport.TNonblockingServerSocket;
import org.apache.thrift.transport.TTransportException;

import com.wutianyi.thrift.example.CalculatorHandler;
import com.wutianyi.thrift.tutorial.Calculator;
import com.wutianyi.thrift.tutorial.Calculator.Processor;

/**
 * @author wutianyi
 * 
 */
public class Server {

	public static void main(String[] args) {

		try {
			TNonblockingServerSocket tServerSocket = new TNonblockingServerSocket(9090);
			CalculatorHandler handler = new CalculatorHandler();
			Processor processor = new Calculator.Processor(handler);

			TServer server = null;
			server =
					new TNonblockingServer(new Args(tServerSocket).processor(processor)
							.protocolFactory(new TBinaryProtocol.Factory()));
			server.serve();
		}catch(TTransportException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
